﻿package game 
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.net.LocalConnection;
	import flash.events.StatusEvent;
	import game.events.EventData;
	/**
	 * ...
	 * @author Doan Nguyen Thuy Nha Truc (Bamboo)	
	 */
	
	public class BaseLocalConnection extends EventDispatcher
	{
		public var localConnection:LocalConnection;
		public var connectionName:String;
		public var connectionNameSend:String;
		public function BaseLocalConnection() 
		{
			
		}
		
		public function init(cName,cNameSend):void {
			connectionName = cName;
			connectionNameSend = cNameSend;
			localConnection = new LocalConnection();
			localConnection.allowDomain("*");
			localConnection.allowInsecureDomain("*");
			localConnection.connect(connectionName);
			localConnection.client=this;
		    localConnection.addEventListener(StatusEvent.STATUS, onLocalConnectionStatus);
			//trace("init");
		}
		
		private function onLocalConnectionStatus(statusEvent:StatusEvent):void
		{
			if (statusEvent.level=="error")
			{
				trace(statusEvent.code);
				
			}
		}
		
	}

}